// ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables
import 'package:flutter/material.dart';

import 'package:junyeyishu/widgets/QGWidget.dart';
import 'package:junyeyishu/widgets/QGListState.dart';
import 'package:junyeyishu/widgets/QGNavigationBar.dart';
import '/utils/utils.dart';

class QGNFTSendRecord extends StatefulWidget {
  const QGNFTSendRecord({Key? key}) : super(key: key);
  @override
  State<QGNFTSendRecord> createState() => _QGNFTSendRecordState();
}

class _QGNFTSendRecordState extends QGListState<QGNFTSendRecord> {
  @override
  void initState() {
    super.initState();

    listURL = url_user_getMyPresentList;
    listKey = "list";

    onRefresh();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Color(0xFFFFFFFF),
      body: Column(
        children: [
          buildHeader(),
          buildList(),
        ],
      ),
    );
  }

  buildHeader() {
    return Container(
      color: Color(0xFFFFFFFF),
      child: Column(children: [
        QGNavigationBar(title: "转赠记录"),
        Container(height: 0.5.rpx, color: Color(0xFFEAEAEA)),
      ]),
    );
  }

  @override
  Widget itemBuilder(context, index, dynamic data) {
    return Container(
      margin: EdgeInsets.only(top: 10.rpx, left: 10.rpx, right: 10.rpx),
      padding: EdgeInsets.all(10.rpx),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(6.rpx),
        color: Color(0xFFF8F8F6),
      ),
      child: Column(children: [
        Row(
          children: [
            ClipRRect(
              borderRadius: BorderRadius.circular(4.rpx),
              child: QGImage(
                  url: data?["thumb_img"], width: 62.rpx, height: 62.rpx),
            ),
            SizedBox(width: 10.rpx),
            Expanded(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Expanded(
                        child: Text(
                          data?["nft_name"] ?? "",
                          style: TextStyle(
                              color: Color(0xFF111111),
                              fontSize: 13.rpx,
                              fontWeight: FontWeight.normal),
                        ),
                      ),
                    ],
                  ),
                  SizedBox(height: 5.rpx),
                  Text(
                    data?["address"] ?? "",
                    style: TextStyle(
                        color: Color(0xFF111111),
                        fontSize: 10.rpx,
                        fontWeight: FontWeight.normal),
                  ),
                  SizedBox(height: 5.rpx),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Text(
                        "${data["type"]}成功",
                        style: TextStyle(
                            color: const Color(0xff999999),
                            fontSize: 12.rpx,
                            fontWeight: FontWeight.normal),
                      ),
                      Flexible(
                        child: Text(
                          data?["created"] ?? "",
                          style: TextStyle(
                              color: const Color(0xff999999),
                              fontSize: 12.rpx,
                              fontWeight: FontWeight.normal),
                        ),
                      ),
                    ],
                  ),
                ],
              ),
            ),
          ],
        ),
        // SizedBox(height: 10.rpx),
        // Container(
        //     height: 0.5.rpx, color: const Color.fromRGBO(255, 255, 255, 0.2)),
        // SizedBox(height: 10.rpx),
        // buildState(),
      ]),
    );
  }

// "address": "0x1ba16546ca20D61E285ffaAf31A681F025aB56Bb",
//                 "type": "转出",
//                 "nft_name": "火",
//                 "thumb_img": "https://assets.dreamverse.site/honglin/202206/20220624053425761.jpg",
//                 "created": "2023-03-29 20:11:29"
//             },
}
